//导入模块
const http = require('http')

//创建服务对象
const server = http.createServer((request, response) => {
    //实例化URL对象
    let url = new URL(request.url, 'http://127.0.0.1');

    //输出路径
    console.log(url.pathname);

    //输出keyword查询字符串
    console.log(url.searchParams.get('keyword'));
    
    //浏览器访问完成时执行代码，输出显示在网页中
    response.end('url new');
});

//监听窗口，启动服务时执行代码
server.listen(9000, () => {
    console.log('服务已经启动……');
});